package com.hundsun.bible.facade.impl.account;

import org.springframework.transaction.annotation.Transactional;

import com.hundsun.bible.domain.Enum.EnumSubTransCode;
import com.hundsun.bible.domain.model.AmountSecurity;
import com.hundsun.bible.domain.model.acctrans.AccountTransResult;
import com.hundsun.bible.domain.model.acctrans.FreezeBalanceReq;
import com.hundsun.bible.domain.util.Money;
import com.hundsun.bible.facade.account.AmountSecurityManager;
import com.hundsun.bible.facade.acctrans.AccountTransManager;

public class AmountSecurityManagerImpl implements AmountSecurityManager {
    private AccountTransManager accountTransManager;

    public AccountTransManager getAccountTransManager() {
        return accountTransManager;
    }

    public void setAccountTransManager(AccountTransManager accountTransManager) {
        this.accountTransManager = accountTransManager;
    }

    //余额转保证金
    @Transactional
    public String amountSecuritySubS(AmountSecurity amountSecurity) {
        String statusMessage = "0";

        FreezeBalanceReq ReqFreeze = new FreezeBalanceReq();
        ReqFreeze.setAccountNo(amountSecurity.getAccountNo());
        ReqFreeze.setAmount(new Money(amountSecurity.getTransAmountStr()));
        ReqFreeze.setSubTransCode(EnumSubTransCode.TXCODE_ACCOUNT_SECURITY_FREEZE);
        AccountTransResult result = accountTransManager.execute(ReqFreeze);
        if (result != AccountTransResult.TXN_RESULT_SUCCESS) {
            statusMessage = result.getMessage();
        }

        return statusMessage;
    }

}
